cmake_minimum_required(VERSION 3.10.0)
project(stock_system VERSION 0.1.0 LANGUAGES C CXX)
set(CMAKE_CXX_STANDARD 17)
set(CMAKE_CXX_STANDARD_REQUIRED ON)
set(CMAKE_EXPORT_COMPILE_COMMANDS ON)

# 确保Qt MOC能够正确处理带有Q_OBJECT的类
set(CMAKE_AUTOMOC ON)
set(CMAKE_AUTORCC ON)
set(CMAKE_AUTOUIC ON)
set(CMAKE_INCLUDE_CURRENT_DIR ON)

# 必要的依赖包
find_package(CURL REQUIRED)
find_package(OpenSSL REQUIRED)
find_package(Qt5 COMPONENTS Widgets Core Gui Charts REQUIRED)

# 确保包含路径正确配置，使MOC可以找到这些头文件
include_directories(
  ${CMAKE_CURRENT_SOURCE_DIR}
  ${CMAKE_CURRENT_BINARY_DIR}
)

if(CMAKE_COMPILER_IS_GNUCXX OR CMAKE_CXX_COMPILER_ID MATCHES "Clang")
add_compile_options(-Wall -Wextra -Wpedantic)
endif()

add_compile_options(-O3)
find_package(Qt5 COMPONENTS Widgets Core Gui Charts REQUIRED)

include_directories(
  include
  ${Qt5Widgets_INCLUDE_DIRS}
  ${Qt5Core_INCLUDE_DIRS}
  ${Qt5Gui_INCLUDE_DIRS}
  ${Qt5Charts_INCLUDE_DIRS}
)

# 添加资源文件
set(RESOURCE_FILES
  resources.qrc
)

# 头文件列表
set(HEADER_FILES
  include/tools/Hash.hpp
  include/market_data_manager.hpp
  include/stock.hpp
  include/trading_system.hpp
  include/transaction_record.hpp
  include/user_account.hpp
  include/user.hpp
  include/tools/stock_table_delegate.hpp
  include/widgets/main_window.hpp
  include/widgets/portfolio_widget.hpp
  include/widgets/report_widget.hpp
  include/widgets/stock_info_widget.hpp
  include/widgets/trading_widget.hpp
  include/widgets/register_dialog.hpp
  include/widgets/login_dialog.hpp
)

# 源文件列表
set(SOURCE_FILES
  main.cpp
  src/user.cpp
  src/stock.cpp
  src/user_account.cpp
  src/transaction_record.cpp
  src/market_data_manager.cpp
  src/trading_system.cpp
  src/tools/stock_table_delegate.cpp
  src/widgets/main_window.cpp
  src/widgets/stock_info_widget.cpp
  src/widgets/trading_widget.cpp
  src/widgets/portfolio_widget.cpp
  src/widgets/report_widget.cpp
  src/widgets/register_dialog.cpp
  src/widgets/login_dialog.cpp
)

add_executable(stock_system ${SOURCE_FILES} ${HEADER_FILES} ${RESOURCE_FILES})
target_link_libraries(${PROJECT_NAME}
  Qt5::Widgets
  Qt5::Core
  Qt5::Gui
  Qt5::Charts
  CURL::libcurl
  OpenSSL::SSL
  OpenSSL::Crypto
  )

